/*
package com.budwk.app.ocr_general;


import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.plaf.ProgressBarUI;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.function.Consumer;

*/
/**
 * @title: CreateImageWatermarkDemo
 * @Author Tan
 * @Date: 2023/6/14 15:37
 * @Version 1.0
 *//*

public class CreateImageWatermarkDemo {

    private static  BufferedImage targetImage;

    private static JTextField Resultarea;

    private static JProgressBar ProgressBar;

    static {
        try {
            targetImage = ImageIO.read(new File("D:\\CESHI\\IMG\\89bc-e86791e8e463c027bc463eccb21c2952.jpg"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


   */
/* public static void main(String[] args) throws IOException {

        execute();
    }*//*


    // 执行OCR识别
    */
/*private static void execute() throws IOException {
        BufferedImage targetImage=ImageIO.read(new File("D:\\CESHI\\IMG\\89bc-e86791e8e463c027bc463eccb21c2952.jpg"));
        String tempImage="D:\\CESHI\\IMG\\89bc-e86791e8e463c027bc463eccb21c2952.jpg";
        try {
            File tempFile = new File(tempImage);
            if (tempFile == null) {
                tempFile.mkdirs();
            }
            tempFile.mkdirs();
            ImageIO.write(targetImage, "jpg", tempFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        File file = new File(tempImage);

        ITesseract instance = new Tesseract();
        // 设置语言库位置
        instance.setDatapath("D:\\workspace\\OcrLanguageLibrary\\");
        // 设置语言
        String language="chi_sim";
        instance.setLanguage(language);
        Thread thread = new Thread() {
            public void run() {
                String result = null;
                try {
                    result = instance.doOCR(file);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //System.out.println("result============"+result);
                Resultarea.setText(result);
            }
        };

        ProgressBar.show(this, thread, "图片正在识别中，请稍后...", "执行结束", "取消");
    }*//*




    public static void main(String[] args) {
        Tesseract instance = new Tesseract();
        instance.setDatapath("C:\\Program Files\\Tesseract-OCR\\tessdata");
        instance.setLanguage("chi_sim1");
        File imageFile = new File("D:\\CESHI\\IMG\\testImage.jpg");
        try {
            String result = instance.doOCR(imageFile);
            System.out.println("RESULT=========="+result+"============");
        } catch (TesseractException e) {
            e.printStackTrace();
        }
    }









    */
/*public static void createImageWatermark(DcsClient client) throws IOException {

        CreateImageWatermarkRequest request = new CreateImageWatermarkRequest();

        // 创建File对象和FileInputStream对象
        File file = new File("demo.jpg");
        FileInputStream fis = new FileInputStream(file);

        CreateImageWatermarkRequestBody body = new CreateImageWatermarkRequestBody()
                // 文件传参
                .withFile(fis, file.getName())
                .withBlindWatermark("test123");
        request.setBody(body);

        CreateImageWatermarkResponse response = client.createImageWatermark(request);
        fis.close();

        //下载文件的consumer
        Consumer<InputStream> consumer = inputStream -> {
            try {
                FileOutputStream out = new FileOutputStream("D:\\CESHI\\IMG\\89bc-e86791e8e463c027bc463eccb21c2952.jpg");
                byte[] data = new byte[1024];
                int len = 0;
                while ((len = inputStream.read(data))!= -1) {
                    out.write(data, 0, len);
                }

                inputStream.close();
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        };

        //下载文件
        response.consumeDownloadStream(consumer);
    }

    public static void main(String[] args) throws IOException {
        String ak = "{ITKU2WJIHNKCFYG55WL6}";
        String sk = "{8L1qI6UbDBeW13YcHp3ZqKYzpiTQVmT16yrXp4Xv}";
        String endpoint = "{your endpoint string}";
        String projectId = "{07f6e95e8f2f4c45b51148bad73a01b2}";
        HttpConfig config = HttpConfig.getDefaultHttpConfig();
        config.withIgnoreSSLVerification(true);
        BasicCredentials auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk)
                .withProjectId(projectId);

        DcsClient client = DcsClient.newBuilder()
                .withHttpConfig(config)
                .withCredential(auth)
                .withEndpoint(endpoint)
                .build();

        createImageWatermark(client);

    }*//*

}
*/
